package de.carcophan.archiver.gui;

import de.carcophan.archiver.BackupEventListener;
import javafx.application.Platform;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.GridPane;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.stage.Stage;


/**
 * Created by  on 17.04.2014.
 */
public class ArchiveWindow implements BackupEventListener {


  private String backupMessage;

  private String futureMessage;

  private Label lastDate;

  private Label nextDate;


  public ArchiveWindow() {
  }

  public void start(Stage primaryStage) throws Exception {

    primaryStage.setTitle("Archiver");
    GridPane grid = new GridPane();
    grid.setAlignment(Pos.BASELINE_LEFT);
    grid.setHgap(5);
    grid.setVgap(10);
    grid.setPadding(new Insets(25, 25, 25, 25));

    Label last = new Label("Last Backup:");
    last.setFont(Font.font("Tahoma", FontWeight.BOLD, 11));
    grid.add(last, 0, 1);


    lastDate = new Label();
    grid.add(lastDate, 1, 1);

    Label next = new Label("Next Backup:");
    next.setFont(Font.font("Tahoma", FontWeight.BOLD, 11));
    grid.add(next, 0, 2);

    nextDate = new Label();
    grid.add(nextDate, 1, 2);

    Scene scene = new Scene(grid, 320, 110);
    primaryStage.setScene(scene);
    primaryStage.show();

  }

  @Override
  public void onBackupEvent(String backupMessage, String futureMessage) {
    Platform.runLater(new Runnable() {
      @Override
      public void run() {
        nextDate.setText(futureMessage);
        lastDate.setText(backupMessage);
      }
    });
  }
}
